<?php
  global $wpdb;
  if (!$wpdb)
	  require_once('../../../wp-load.php');
  //coming from manage scope -- make fields editable.
  $keyword = $_REQUEST[scope];
  $from_manage = false;
  if ($keyword) {
	  $from_manage = true;
  } else {
	  $keyword = $_POST["ID"];	 
  }  
  $all_problems = $wpdb->get_results($wpdb->prepare("SELECT title, problem, name, email, url, date_created  FROM {$wpdb->prefix}scope WHERE ID=%d", $keyword));		  
  if (count($all_problems)) {
	  foreach ($all_problems as $scope) { 
?>
	 
<div class="wrap">
<h2><?php echo 'Viewing Problem: ';  echo $keyword; ?></h2>
<input type="hidden" id="title" name="ignore_me" value="This is here for a workaround for a editor bug" />
<!-- http://umbcs.org/scope/wp-admin/wp-content/plugins/scope/get_submission.php -->
<!-- <form name="post" action="wp-content/plugins/scope/get_submission.php" method="post" id="post"> -->
<form name="post" action="edit.php?page=scope/get_submission.php" method="post" id="post">

<div id="poststuff">
	<div class="postbox">
		<h3 class="hndle">
			<span>
				<?php echo 'Title:' ?>
			</span>
		</h3>
		<div class="inside">
			<input type="text" size="75" name="title_u" value="<?php echo $scope->title ?>" <?php if (!$from_manage) { ?> readonly="readonly" <?php } else {} ?> />
		</div>
	</div>
	<div class="postbox">
		<h3 class="hndle">
			<span>
				<?php echo 'Problem:' ?>
			</span>
		</h3>
		<div class="inside">
			<?php echo $scope->problem ?>
		</div>
	</div>
	<div class="postbox">
		<h3 class="hndle">
			<span>
				<?php echo 'URL:' ?>
			</span>
		</h3>
		<div class="inside">
			<a href="<?php echo $scope->url ?>"  target="_blank"><?php echo $scope->url ?></a><br />
			 <?php if ($from_manage) {  ?>
				<input type="text" size="75" name="url_u" value="<?php echo $scope->url  ?>" />
			<?php } else {}  ?>
		</div>
	</div>
	<?php	 if ($from_manage) { 	?>     
	<div class="postbox">
		<h3 class="hndle">
			<span>
				<?php echo 'Name:' ?>
			</span>
		</h3>
		<div class="inside">
			<input type="text" size="75" name="name_u" value="<?php echo $scope->name ?>"  />
		</div>
	</div>
	<div class="postbox">
		<h3 class="hndle">
			<span>
				<?php echo 'Email:' ?>
			</span>
		</h3>
		<div class="inside">
			<input type="text" size="75" name="email_u" value="<?php echo $scope->email ?>" />
		</div>
	</div>
	<p class="submit"> 	
		<input type="submit" name="submit" value="Save" />
	</p>
	<?php  }}} ?>			
	</div>
</FORM>
</div>